package org.darkforest.common.services.impl;

import org.darkforest.common.services.StoreClassService;
import org.darkforest.dao.mapper.StoreClassMapper;
import org.darkforest.model.StoreClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2015/12/16.
 */
@Service
public class StoreClassServiceImpl implements StoreClassService {

    @Autowired
    private StoreClassMapper storeClassMapper;


    @Override
    public int deleteByPrimaryKey(Integer scId) {
        return storeClassMapper.deleteByPrimaryKey(scId);
    }

    @Override
    public int insert(StoreClass record) {
        return storeClassMapper.insert(record);
    }

    @Override
    public int insertSelective(StoreClass record) {
        return storeClassMapper.insertSelective(record);
    }

    @Override
    public StoreClass selectByPrimaryKey(Integer scId) {
        return storeClassMapper.selectByPrimaryKey(scId);
    }

    @Override
    public int updateByPrimaryKeySelective(StoreClass record) {
        return storeClassMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(StoreClass record) {
        return storeClassMapper.updateByPrimaryKey(record);
    }

    /**
     * 店铺分类分页列表
     *
     * @param storeClass
     * @return
     */
    @Override
    public StoreClass selectListByPage(StoreClass storeClass) {
        storeClass.setResultList(storeClassMapper.selectListByCondition(storeClass));
        return storeClass;
    }

    /**
     * 根据条件查询店铺分类
     *
     * @param storeClass
     * @return
     */
    @Override
    public List<StoreClass> selectListByCondition(StoreClass storeClass) {
        return storeClassMapper.selectListByCondition(storeClass);
    }

    /**
     * 批量删除店铺分类
     *
     * @param ids
     * @return
     */
    @Override
    public int delStoreClassBatch(String[] ids) {
        List<String> list = new ArrayList<String>();
        for(String id:ids){
            list.add(id);
        }
        return storeClassMapper.delStoreClassBatch(list);
    }

    /**
     * 根据名称查询除自身之外的相同的数据
     *
     * @param map
     * @return
     */
    @Override
    public List<StoreClass> checkStoreNameExceptSelf(Map<String, Object> map) {
        return storeClassMapper.checkStoreNameExceptSelf(map);
    }
}
